import { post, postFormData, get } from '../../http'
import store from '@/store'

export const registFlt = data => {
  if (data.fltType == 'PT' || data.fltType == 'GYS') {
    data.fltCode = data.fltType + Math.abs(store.state.user.FLT_UUID_DX_H)
  } else {
    data.fltCode = data.fltType + store.state.user.DPTID_DX_H
  }
  data.fltCreator = store.state.user.USR_CODE_DX_H
  return post('/FTKJWLHYPT/contract/register', {
    Data: {
      Parameters: {
        FTKJWLHYPT: data,
      },
    },
  })
}

export const findRglist = data => {
  console.log(data)
  if (data.fltType === 'GYS') {
    data.fltCode = data.fltType + Math.abs(store.state.user.FLT_UUID_DX_H)
  } else if (data.fltType === 'PT') {
    data.fltCode = ''
  } else {
    data.fltCode = data.fltType + store.state.user.DPTID_DX_H
  }
  return post('/FTKJWLHYPT/contract/findRglist', {
    Data: {
      Parameters: {
        FTKJWLHYPT: data,
      },
      PageIndex: {
        FTKJWLHYPT: data.currentPage,
      },
      PageSize: {
        FTKJWLHYPT: data.pageSize,
      },
    },
  })
}

export const viewMessage = data => {
  return post('/FTKJWLHYPT/contract/viewMessage', {
    Data: {
      Parameters: {
        FTKJWLHYPT: data,
      },
    },
  })
}

export const certificateRequest = data => {
  return post('/FTKJWLHYPT/contract/certificateRequest', {
    Data: {
      Parameters: {
        FTKJWLHYPT: data,
      },
    },
  })
}

export const selectRegistCount = data => {
  return post('/FTKJWLHYPT/contract/selectRegistCount', {
    Data: {
      Parameters: {
        FTKJWLHYPT: data,
      },
    },
  })
}

/**
 * 印章上传
 * @param {} data
 */
export const upsealDocument = data =>
  postFormData('/FTKJWLHYPT/' + 'sealUpload/' + data.id + '/' + store.state.user.USR_CODE_DX_H + '/' + data.customerId, data.file)

export const beforeSign = data => {
  return post('/FTKJWLHYPT/contract/beforeSign', {
    Data: {
      Parameters: {
        FTKJWLHYPT: data,
      },
    },
  })
}

export const lineSign = data => get('/FTKJWLHYPT/' + 'lineSign/' + data.id + '/' + data.fltCode)
